<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Log;
use Hyperf\Cache\Cache;
use Hyperf\Context\ApplicationContext;
use Hyperf\DbConnection\Db;
use function Hyperf\Support\env;

use GuzzleHttp\Client;
use Hyperf\Guzzle\CoroutineHandler;
use GuzzleHttp\HandlerStack;

class TestController extends AbstractController
{
    public function index()
    {
        $user = $this->request->input('test', 'test');
        $method = $this->request->getMethod();

        $mobile=$this->request->input('mobile', '');

        Log::get('default','default')->info(__CLASS__.__METHOD__);
        Log::get('mypay','mypay')->info(__CLASS__.__METHOD__);

        $port=env('DB_PORT');
        $sql="select * from admin_roles;";
        $list=Db::select($sql);

        $client = new Client([
            'base_uri' => 'https://jsonplaceholder.typicode.com',
            'handler'  => HandlerStack::create(new CoroutineHandler()),
            'timeout'  => 5,
            'swoole'   => [
                'timeout'            => 10,
                'socket_buffer_size' => 1024 * 1024 * 2,
            ],
        ]);

//        $resp = $client->get('/todos/1');
        $resp = $client->post('/todos/1',[]);

        $container = ApplicationContext::getContainer();
//        $container->get()

        return $resp->getBody();
    }
}
